{% extends 'endbase.html' %}

{% block title %}
	博客管理
{% endblock %}

{% block head %}
	<style>
        .small-container{
            margin-top: 20px;
            margin-bottom: 20px;
        }
    </style>
{% endblock %}
{% block body %}
<div class="container" style="height: 100vh">
    <div class="row form-horizontal" style="margin: 10px 0 30px -15px ;">
            <form action="{{ url_for('security.search_blog') }}" method="post">
                <div class="form-group col-md-4">
                <label for="theme" class="control-label col-md-2 titleblog">标题</label>
                <div class="col-md-10">
                    <input id="theme" name="theme" class="form-control" placeholder="标题搜索" style="text-decoration: none;outline: none; font-size: 15px;" >
                </div>
            </div>
                <div class="form-group col-md-2 statusblog ">
                    <div class="col-md-12">
                        <select class=" form-control" id="statusblog" name="statusblog">
                            <option value=" ">选择状态过滤</option>
                            <option value="published">已发布</option>
                            <option value="draft">草稿</option>
                        </select>
                    </div>

                </div>
                <div class="form-group categoryblog col-md-4">
                    <div class="col-md-12">
                        <label class="control-label col-md-3"> 分类</label>
                        <div class="col-md-9">
                            <select class=" form-control  " id="categoryblog" name="categoryblog">
                            <option value=" ">请选择</option>
                            {% for category in categories %}
                                <option value="{{ category.id }}">{{ category.name }}</option>
                            {% endfor %}
                        </select>
                        </div>
                    </div>
                </div>
                <div class="form-group col-md-2 text-right">
                    <div class="col-md-12">
                        <button class="btn-danger btn" style="width: 80px" id="manager" name="search" value="manager">搜索</button>
                    </div>
                </div>
            </form>
    </div>

    <div class="row" style="margin-top: -25px;margin-left: 0">
        <button class="btn-danger btn" style="width: 100px;color: black">
            <a href="{{ url_for('security.write_blog') }}" style="color: black;outline: none;text-decoration: none">新建博客</a>
        </button>
    </div>
    <div class="bloglist">
        <table class="table table-condensed">
            <thead>
                <tr>
                    <th class="col-md-1" >封面</th>
                    <th class="col-md-4">文章信息</th>
                    <th class="col-md-1">编辑器</th>
                    <th class="col-md-1">类型</th>
                    <th class="col-md-1">状态</th>
                    <th class="col-md-3">时间</th>
                    <th class="col-md-1">操作</th>
                </tr>
            </thead>
            <tbody>
                {% for blog in blogs %}
                <tr>
                    <td>
                        {% if blog.picture %}
                        <img src="{{ url_for('static',filename=blog.picture) }} " style="width: 100px;height: 100px;">
                        {% else %}
                        <img src="{{ url_for('static',filename='images/1.jpg') }} " style="width: 100px;height: 100px;">
                        {% endif %}
                    </td>
                    <td>
                        <div class="small-container" style="margin-top: 20px;margin-bottom: 20px">
                            <div>标题：{{ blog.title }}</div>
                            <div>分类：{{ blog.categorie.name }}</div>
                            <div>作者：{{ blog.author.username }}</div>
                        </div>

                    </td>
                    <td><div class="small-container">Markdown</div></td>
                    <td><div class="small-container">原创</div></td>
                    <td>
                        {% if blog.status == 'published' %}
                            <div class="small-container">已发布</div>
                        {% else %}
                            <div class="small-container">草稿</div>
                        {% endif %}
                    </td>
                    <td>
                        <div class="small-container">
                            <div>创建时间：{{ blog.create_time }}</div>
                            <div>更新时间：{{ blog.update_time }}</div>
                        </div>
                    </td>
                    <td>
                        <div class="small-container"><a href="{{ url_for('security.edit_blog',blog_id=blog.id) }}">编辑</a> | <a href="{{ url_for('security.delete_blog',blog_id=blog.id) }}">删除</a> </div>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

</div>
{% endblock %}